package com.systop.ltbook.order.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.systop.core.model.BaseModel;
import com.systop.ltbook.book.model.Book;

@Entity
@Table(name="order_item")
@SuppressWarnings("serial")
public class OrderItem extends BaseModel {

	/** 主键 */
	private Integer id;
	
	/** 订单 */
	private OrderForm orderForm;
	
	/** 对应图书 */
	private Book book;
	
	/** 具体执行单价 用于计算金额 */
	private Double truePrice;
	
	/** 数量 */
	private Integer count;
	
	/** 金额 */
	private Double money;
	
	/** 描述 */
	private String descn;

	@Id
	@GeneratedValue(generator = "hibseq")
	@GenericGenerator(name = "hibseq", strategy = "hilo")
	@Column(name = "ID", nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name="form_id")
	public OrderForm getOrderForm() {
		return orderForm;
	}

	public void setOrderForm(OrderForm orderForm) {
		this.orderForm = orderForm;
	}


	//在图书类中没必要再建立双向映射
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name="book_id")
	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}
	
	public Double getTruePrice() {
		return truePrice;
	}

	public void setTruePrice(Double truePrice) {
		this.truePrice = truePrice;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public Double getMoney() {
		return money;
	}

	public void setMoney(Double money) {
		this.money = money;
	}

	public String getDescn() {
		return descn;
	}

	public void setDescn(String descn) {
		this.descn = descn;
	}

}
